
fetch("http://chst.vip:1234/api/getmoneyctrl")
        .then(body => body.json())
        .then(res => {
             console.log(res);
            let html = "";
            res.result.forEach(item => {
                html += `
                <li productid=${item.productId}>
                   <div>${item.productImg2}</div> 
                   <div class="infoR">
                    <div><h1>${item.productName}</h1></div>
                    <div class="infor"> 
                        <div>
                            <span class="mall fl">${item.productFrom} | ${item.productTime}</span>
                            <i class="iconfont icon-xiaoxi fr">${item.productComCount}</i>
                        </div>
                    </div>
                    </div>         
                </li>
                `
            })
            uu.innerHTML = html;
            let lis = document.querySelectorAll('li');
            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    location.href = "../pages/discount.html?productid=" + productid
                }
            })
        })


        let page = document.querySelector('.page')
      
        let prev = document.querySelector('#prev')
        // console.log(prev);
        let next = document.querySelector('#next')
        // console.log(next);
        let pageid = 1;

        page.onchange=()=>{ 
        pageid = page.value.replace(/\s*/g,"").split("/")[0]
        fetch(`http://chst.vip:1234/api/getmoneyctrl?pageid=${pageid}`)
        .then(body => body.json())
        .then(res => {
             
            let html = "";
            res.result.forEach(item => {
                html += `
                <li productid=${item.productId}>
                   <div>${item.productImg2}</div> 
                   <div class="infoR">
                    <div><h1>${item.productName}</h1></div>
                    <div class="infor"> 
                        <div>
                            <span class="mall fl">${item.productFrom} | ${item.productTime}</span>
                            <i class="iconfont icon-xiaoxi fr">${item.productComCount}</i>
                        </div>
                    </div>
                    </div>         
                </li>
                `
            })
            uu.innerHTML = html;
            let lis = document.querySelectorAll('li');
            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    location.href = "../pages/discount.html?productid=" + productid
                }
            })
            
        })
    
        if(pageid>1){
        prev.disabled="";
        prev.style.color='rgb(51, 51, 51)'
        }else{
        prev.disabled=true;
        prev.style.color='rgb(204, 204, 204)'
        }
        if(pageid<14){
            next.disabled="";
            next.style.color='rgb(51, 51, 51)'
            }else{
                next.disabled=true;
                next.style.color='rgb(204, 204, 204)'
            }
        }
        prev.onclick=()=>{
            
            pageid--
            fetch(`http://chst.vip:1234/api/getmoneyctrl?pageid=${pageid}`)
        .then(body => body.json())
        .then(res => {
             
            let html = "";
            res.result.forEach(item => {
                html += `
                <li productid=${item.productId}>
                   <div>${item.productImg2}</div> 
                   <div class="infoR">
                    <div><h1>${item.productName}</h1></div>
                    <div class="infor"> 
                        <div>
                            <span class="mall fl">${item.productFrom} | ${item.productTime}</span>
                            <i class="iconfont icon-xiaoxi fr">${item.productComCount}</i>
                        </div>
                    </div>
                    </div>         
                </li>
                `
            })
            uu.innerHTML = html;
            let lis = document.querySelectorAll('li');
            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    location.href = "../pages/discount.html?productid=" + productid
                }
            })
            
        })
    
        if(pageid>1){
            prev.disabled="";
            prev.style.color='rgb(51, 51, 51)'
            }else{
            prev.disabled=true;
            prev.style.color='rgb(204, 204, 204)'
            }
            if(pageid<14){
                next.disabled="";
                next.style.color='rgb(51, 51, 51)'
                }else{
                    next.disabled=true;
                    next.style.color='rgb(204, 204, 204)'
                }
            $(".page").val(`${pageid}/14`)
        }
        next.onclick=()=>{
            
            pageid++
            fetch(`http://chst.vip:1234/api/getmoneyctrl?pageid=${pageid}`)
        .then(body => body.json())
        .then(res => {
             
            let html = "";
            res.result.forEach(item => {
                html += `
                <li productid=${item.productId}>
                   <div>${item.productImg2}</div> 
                   <div class="infoR">
                    <div><h1>${item.productName}</h1></div>
                    <div class="infor"> 
                        <div>
                            <span class="mall fl">${item.productFrom} | ${item.productTime}</span>
                            <i class="iconfont icon-xiaoxi fr">${item.productComCount}</i>
                        </div>
                    </div>
                    </div>         
                </li>
                `
            })
            uu.innerHTML = html;
            let lis = document.querySelectorAll('li');
            [...lis].forEach(li => {
                li.onclick = function () {
                    let productid = this.getAttribute("productid")
                    location.href = "../pages/discount.html?productid=" + productid
                }
            })
            
        })
    
        if(pageid>1){
            prev.disabled="";
            prev.style.color='rgb(51, 51, 51)'
            }else{
            prev.disabled=true;
            prev.style.color='rgb(204, 204, 204)'
            }
        if(pageid<14){
            next.disabled="";
            next.style.color='rgb(51, 51, 51)'
            }else{
                next.disabled=true;
                next.style.color='rgb(204, 204, 204)'
            }
            $(".page").val(`${pageid}/14`)
        }


